var buttons = document.getElementsByClassName('shuru2');
var items = document.getElementsByClassName('item');

for (var i = 0; i < buttons.length; i++) {
    buttons[i].setAttribute('data-index', i); // setAttribute(param1, param2) 设置自定义属性, 第一个参数是自定义属性名,第二个参数是属性值;
    buttons[i].onmouseover = function() {
        for (var j = 0; j < items.length; j++) {
            items[j].style.display = 'none';
            buttons[j].style.borderBottom = '1px solid #fff';
            buttons[j].style.color = 'black'
        }
        // 修改当前按钮和内容的样式
        var index = this.getAttribute('data-index'); // 获取当前被点击元素的索引值
        console.log(index);
        buttons[index].style.color = 'red'
        buttons[index].style.borderBottom = '2px solid black';
        items[index].style.display = 'block';
    }
}